<template>
    <div>
        <el-form :inline="true" :model="formInline" class="demo-form-inline">
            <el-form-item label="地址信息所属城市">
                <el-input v-model="formInline.city" placeholder="xx市/xx地区"></el-input>
            </el-form-item>
            <el-form-item label="地址类型">
                <el-select v-model="formInline.region" placeholder="活动区域">
                    <el-option label="景区" value="landmark"></el-option>
                    <el-option label="酒店" value="hotel"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="onSubmit">更新</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
export default {
    name: "datainit",
    data() {
        return {
            formInline: {
                city: '',
                region: ''
            }
        }
    },
    methods: {
        onSubmit() {
            if (this.formInline.region == "landmark") {
                this.$api.dataInitApi.landmarksInit({ city: this.formInline.city }).then(res => {
                    if (res.data.code == 1) {
                        this.$notify({
                            title: "成功",
                            message: "数据完全导入！",
                            type: "success",
                        });
                    } else {
                        this.$notify.error({
                            title: "错误",
                            message: res.data.msg,
                        });
                    }
                })
            }
            else if (this.formInline.region == "hotel") {
                this.$api.dataInitApi.hotelsInit({ city: this.formInline.city }).then(res => {
                    if (res.data.code == 1) {
                        this.$notify({
                            title: "成功",
                            message: "数据完全导入！",
                            type: "success",
                        });
                    } else {
                        this.$notify.error({
                            title: "错误",
                            message: res.data.msg,
                        });
                    }
                })
            }
        }
    },
    mounted() {

    },
}
</script>